#ifndef _XMLDATAREADER_H_
#define _XMLDATAREADER_H_
#include "CombatDef.h"
class StringRow
{
	friend class XmlDataReader;
public:
	
	uint32 CellNum() const  { return m_vCellData.size();}

	const std::string&  StringAt(uint32 iIndex)   const
	{ 
		return  m_vCellData[iIndex]; 
	}

	int32	Atoi(uint32 iIndex,int32 iDefault=INVALID_ID) const
	{
		if(!m_vCellData[iIndex].empty())
			return ::atoi(m_vCellData[iIndex].c_str());
		else
			return iDefault;
	}	
	
	double Atof(uint32 iIndex,double fDefault=0.f) const
	{
		if(!m_vCellData[iIndex].empty())
			return ::atof(m_vCellData[iIndex].c_str());
		else
			return fDefault;
	}
	bool Atob(uint32 iIndex,bool bDefault=false) const
	{
		if(!m_vCellData[iIndex].empty())
			return Atoi(iIndex)!=0;
		else
			return bDefault;

	}
private:
	std::vector<std::string> m_vCellData;
};

class XmlDataReader
{
public :
		XmlDataReader();
		bool ReadFromFile(const char * szFileFullPath);
		
		uint32 RowNum() const 
		{ 
			return m_iRowNum;
		}
		uint32 ColumnNum() const 
		{ 
			return m_iColumnNum;
		}
		const StringRow& RowAt(uint32 iIndex)  const 
		{
			return m_vRows[iIndex]; 
		}
private :
	std::vector<StringRow> m_vRows;
	uint32 m_iRowNum;
	uint32 m_iColumnNum;
};
#endif
